#include "intArray_t.h"
#include <iostream>

using namespace std;

int main() {
	intArray_t arr;
	int curInsert = 1;
	bool first = true;


	while(1) {
		cout <<
			"\n| n | c | fst | lst | empty | ins | rmv | RmvAll |A|P| < | : ";

		char c;
		cin >> c;

		if(c!='n' && c!='f' && c!='l' && c!='e' && c!='i'
			&& c!='r' && c!='R' && c!='<'
			&& c!='A' && c!='P' && c!='c' )   break;
		if (first) {
			first = false;
		}
		else {

		}


		switch (c) {
		   case 'n' :  cout << arr.getNumberOfElements() << endl;  break;
		   case 'f' :  cout << *arr.getFirstElement() << endl;      break;
		   case 'l' :  cout << *arr.getLastElement() << endl;       break;
		   case 'e' :  cout << (arr.isEmpty() ? "Empty" : "No") << endl;
			   break;
		   case 'c' :  //print capacity
			   cout << arr.getCapacity();
			   break;
		   case 'i' :  
			   cout << "inserted " << curInsert << endl;
			   arr.insertNewElement(new int(curInsert++));
			   break;
		   case 'r' :  // remove
			   arr.remove(5);
			   arr.remove(10);
			   break;
		   case 'R' :  // remove all
			   arr.removeAll();
			   break;
		   case 'A' :  // append
			   cout << "appending " << curInsert << endl;
			   arr.append(3, new int(curInsert++));
			   break;
		   case 'P' :  // prepend
			   cout << "prepending " << curInsert << endl;
			   arr.prepend(3, new int(curInsert++));
			   break;
		   case '<' :  // print and empty array
			   while (!arr.isEmpty()) {
				   int *j = arr.getFirstElement();
				   cout << "\t" << *j;
				   arr.removeAndDeleteElement(*j);
			   }
			   break;
		}
	}

	return 0;
}